package leetcode.code;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import leetcode.IDebug;

public class Solution229 implements IDebug {
	public List<Integer> majorityElement(int[] nums) {
		Map<Integer, Integer> times = new HashMap<>();
		for (int num : nums) {
			int time = times.getOrDefault(num, 0);
			times.put(num, time + 1);
		}
		int base = nums.length / 3;
		List<Integer> ans = new ArrayList<>();
		for (Integer num : times.keySet()) {
			if (times.get(num) > base) {
				ans.add(num);
			}
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
